package com.itypd.utils;

import com.itypd.config.AppContextConfig;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/*
 * @Description:
 * @Athor: GongMingwei
 * @version: v1.0
 */
public class PropertiesUtil {

    public static void loadProperties(String filePath) {
        Properties properties = new Properties();
        InputStream input = null;
        try {
            input = new FileInputStream(filePath);//加载Java项目根路径下的配置文件
            properties.load(input);// 加载属性文件
            System.out.println("listen to port:" + properties.getProperty("port"));
            AppContextConfig.PORT = properties.getProperty("port");
        } catch (IOException io) {
            System.out.println(io.getMessage());
        } finally {
            if (input != null) {
                try {
                    input.close();
                } catch (IOException e) {
                    System.out.println(e.getMessage());
                }
            }
        }
    }
}
